Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

142
Vistas
input type="file" id="select-image-base" class="file-upload html5-upload-input" accept="image/*" -- How to upload a file to this element in console?

When I inspect a website, it shows <input type="file" id="select-image-base" class="file-upload html5-upload-input" accept="image/*">

I want to upload an image file to this element found on their website, using a javascript function in Edge.

If I type this into the console in Edge:

document.querySelector('.file-upload').click()

Edge simulates a click to the element.

I can also simulate scrolling with a javascript console line of code.

But how can I send a file to a file-upload element?

I basically want to do the same thing to this element, but instead of a click, I want to send an image file to this drag-and-drop file upload box, using a line of javascript text in the console.

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

No, you can't. The only way to set the value of a file input is by the user selecting a file.

This is done for security reasons. Otherwise you would be able to create a JavaScript that automatically uploads a specific file from the client's computer. You can only choose a file to upload manually.

about 4 years ago · Juan Pablo Isaza Denunciar

0

no, you can't. the way you must do is to push your media through an API

about 4 years ago · Juan Pablo Isaza Denunciar

0

navigate to: https://www.htmlquick.com/reference/tags/input-file.html

If you use this code

function getElementByXpath(path) {
  return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}

var o= getElementByXpath("//section[@id='examples']//input[@name='uploadedfile']")

o.value='z:\test.png'

then you will get:

VM4266:7 Uncaught DOMException: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string.
    at <anonymous>:7:8

This is normal when you do it from the website .

But if you try it with geckodriver.exe then it should be possible.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda